import { useEffect, useMemo, useRef, createContext, useContext } from 'react';
import GetComponentFn from './getComponent';
import innerComponent from './component'
import OpNode from './Node';

const Context = createContext(null);

export function useVisionRootStore():any {
  return useContext(Context)
}
export default (props:any) => {
  let {data, allComponent} = props
  allComponent = {...allComponent, ...innerComponent}
  console.log(data, allComponent)

  // 构建Node一棵树
  const RootNode = data

  console.log(RootNode, 'RootNode')

  const store:any  = {
    allComponent
  }

  return (
    <Context.Provider value={store}>
      <div style={{flex: 1}}>
      {RootNode.children.map((item: any) => {
        return <GetComponentFn item={item} key={item.id} />
      })}
    </div>
    </Context.Provider>
    
  );
};
